@extends('layouts.base')

@section('title',$title)
@section('keyWords',$keyWord)
@section('description',$description)

@section('content')
    <h1 class="text-center">{{$title}}</h1>

    <div class="row">
        <table  id="episodes" class="table table-condensed table-bordered text-center">
            <thead>
            <tr >
                <th>名称</th>
                <th>资源数量</th>
                <th>相关文章</th>
                <th>更新</th>
                <th>创建</th>
            </tr>
            </thead>

            <tbody>
            @foreach($shows as $show)
                <tr>
                    <td >
                        <a href="{{route('show.show',$show)}}">{{$show->full_name}}</a></td>
                    <td>
                        <a href="{{route('show.show',$show)}}">{{$show->episodes()->count()}}</a></td>
                    </td>
                    <td>
                    <a href="#">{{$show->articles()->count()}}</a>
                    </td>
                    <td>{{$show->updated_at->format('m-d H:i')}}</td>
                    <td>{{$show->created_at->diffForHumans()}}</td>
                </tr>
            @endforeach
            </tbody>
        </table>
    </div>
@endsection




@section('rightSideBar')

    <br>
    @if($show->articles()->count())


        <div class="list-group">
            <a href="#" class="list-group-item disabled">
                {{$show->name_en.$show->name_zh.'相关文章'}}
            </a>

            @foreach($show->articles as $article)
                <a class="list-group-item" href="{{route('article.show',$article)}}">{{$article->title}}</a>
            @endforeach

        </div>
    @endif
    <br>
    @include('partials.sidebarShows')
@endsection


@section('ld_json')
    <script type="application/ld+json">
        {
          "@context": "http://schema.org",
          "@type": "BlogPosting",
          "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "{{url()->current()}}"
          },
          "headline": "{{$show->name_en.$show->name_zh }}",
          "image": {
            "@type": "ImageObject",
            "url": "{{$show->coverage_url}}",
            "height": 200,
            "width": 200
          },
          "datePublished": "{{$show->updated_at}}",
          "dateModified": "{{$show->created_at}}",
          "author": {
            "@type": "Person",
            "name": "Eric Zhou"
          },
           "publisher": {
            "@type": "Organization",
            "name": "TRY美剧",
            "logo": {
              "@type": "ImageObject",
              "url": "https://google.com/logo.jpg",
              "width": 600,
              "height": 60
            }
          },
          "description": "{{$show->body}}"
        }
    </script>
@endsection


@section('scripts')
    <script type="text/javascript">
        $('#table').DataTable(
            {
                "paging": true,
                "order": [[3, "desc"]],
                language: {
                    search: "资源页面内搜索:",
                    info: "从第_START_条数据,到第_END_数据.共计_TOTAL_条数据",
                    lengthMenu: "每页显示_MENU_条数据",

                    paginate: {
                        first: "第一页",
                        previous: "上一页",
                        next: "下一页",
                        last: "最后一页"
                    },
                    aria: {
                        sortAscending: "升序",
                        sortDescending: "降序"
                    }
                }
            }
        );
        $(document).on('ready', function() {



            $('#input-rating').rating({clearCaption: '请评分'});
            $('#input-rating').on('rating.change', function (event, value, caption) {
                $.post("{{url('vote/forShow')}}",
                        {
                            '_token': '{{csrf_token()}}',
                            id: "{{$show->id}}",
                            score: value
                        },
                        function (data, status) {
                            var returnScore = data.score.toFixed(2);
                            $('#input-score').rating('update', returnScore);
                            $('#input-rating').rating('refresh', {disabled: true, showClear: false, showCaption: true});
                            $('#vote_count').text(data.vote_count);
                        });

            });
        })
    </script>

@endsection
